﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GameEditor.Common;

namespace TaskSystemClient
{
    public partial class ExportDialog : Form
    {
        public ExportDialog()
        {
            InitializeComponent();
        }

        private void ExportDialog_Load(object sender, EventArgs e)
        {
            tbFileName.Text = LocalSettings.LastExportedFileName;
            cbUseSharedTemplate.Checked = LocalSettings.UseSharedTemplate;
            cbOutputHiddenItems.Checked = LocalSettings.ExportHiddenItems;
            this.comboBoxStyleSelect.Text = LocalSettings.StyleName;
        }

        private void btnExport_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(tbFileName.Text.Trim()))
            {
                Dialogs.Error("请输入有效的文件名！", "导出视图");
                tbFileName.Focus();
                return;
            }
            LocalSettings.UseSharedTemplate = cbUseSharedTemplate.Checked;
            LocalSettings.LastExportedFileName = tbFileName.Text;
            LocalSettings.ExportHiddenItems = cbOutputHiddenItems.Checked;
            LocalSettings.StyleName = this.comboBoxStyleSelect.Text;
            DialogResult = DialogResult.OK;
        }

        private void tbFileName_ButtonClicked(object sender, EventArgs e)
        {

            using (SaveFileDialog dialog = new SaveFileDialog())
            {
                dialog.Filter = "导出为XML格式 (*.xml)|*.xml";
                dialog.FileName = tbFileName.Text;
                if (dialog.ShowDialog() != DialogResult.OK)
                    return;
                tbFileName.Text = dialog.FileName;
            }
        }
    }
}
